package pcjavanet.mobilesell.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import pcjavanet.mobilesell.model.Suppliers;
import pcjavanet.mobilesell.model.PageBean;
import pcjavanet.mobilesell.model.QryCondition;
import pcjavanet.mobilesell.service.SuppliersService;

import com.opensymphony.xwork2.ActionSupport;
@Namespace("/suppliers")
@Controller
@Scope("prototype")
@ParentPackage("json-default")
@Results({
	@Result(name = "success", location = "/view/Suppliers.jsp"),
	@Result(name = "input", location = "/view/Suppliers.jsp")
})

public class SuppliersAction  extends ActionSupport {

  @Resource
  private SuppliersService suppliersService;
  private   java.lang.Integer dbid ;
  private   java.lang.Integer bianhao ;
  private   java.lang.String contact ;
  private   java.lang.String telphone ;
  private   java.lang.String fax ;
  private   java.lang.String mobile ;
  private   java.lang.String email ;
  private   java.lang.String zipcode ;
  private   java.lang.String homepage ;
  private   java.lang.String address ;
  private   java.lang.String blank ;
  private   java.lang.String account ;
  private   java.lang.Integer status ;
  private   java.util.Date createDate ;
  private int start  ;
  private int limit  ;
  private int totalProperty  ;
  private boolean success = true ;
  private String  info ;
  private List<Suppliers>  suppliersPageBeans  ;
  public    java.lang.Integer getDbid() {
   	return this.dbid;
  }
  public void setDbid(  java.lang.Integer  dbid) {
   	 this.dbid=dbid;
  }
  public    java.lang.Integer getBianhao() {
   	return this.bianhao;
  }
  public void setBianhao(  java.lang.Integer  bianhao) {
   	 this.bianhao=bianhao;
  }
  public    java.lang.String getContact() {
   	return this.contact;
  }
  public void setContact(  java.lang.String  contact) {
   	 this.contact=contact;
  }
  public    java.lang.String getTelphone() {
   	return this.telphone;
  }
  public void setTelphone(  java.lang.String  telphone) {
   	 this.telphone=telphone;
  }
  public    java.lang.String getFax() {
   	return this.fax;
  }
  public void setFax(  java.lang.String  fax) {
   	 this.fax=fax;
  }
  public    java.lang.String getMobile() {
   	return this.mobile;
  }
  public void setMobile(  java.lang.String  mobile) {
   	 this.mobile=mobile;
  }
  public    java.lang.String getEmail() {
   	return this.email;
  }
  public void setEmail(  java.lang.String  email) {
   	 this.email=email;
  }
  public    java.lang.String getZipcode() {
   	return this.zipcode;
  }
  public void setZipcode(  java.lang.String  zipcode) {
   	 this.zipcode=zipcode;
  }
  public    java.lang.String getHomepage() {
   	return this.homepage;
  }
  public void setHomepage(  java.lang.String  homepage) {
   	 this.homepage=homepage;
  }
  public    java.lang.String getAddress() {
   	return this.address;
  }
  public void setAddress(  java.lang.String  address) {
   	 this.address=address;
  }
  public    java.lang.String getBlank() {
   	return this.blank;
  }
  public void setBlank(  java.lang.String  blank) {
   	 this.blank=blank;
  }
  public    java.lang.String getAccount() {
   	return this.account;
  }
  public void setAccount(  java.lang.String  account) {
   	 this.account=account;
  }
  public    java.lang.Integer getStatus() {
   	return this.status;
  }
  public void setStatus(  java.lang.Integer  status) {
   	 this.status=status;
  }
  public    java.util.Date getCreateDate() {
   	return this.createDate;
  }
  public void setCreateDate(  java.util.Date  createDate) {
   	 this.createDate=createDate;
  }
  public  void setStart(int start) {
   	 this.start = start;
  }
  public  void setLimit(int limit) {
   	 this.limit = limit;
  }
  public  void setTotalProperty(int totalProperty) {
   	 this.totalProperty = totalProperty;
  }
  public  void setSuppliersPageBeans(List<Suppliers> suppliersPageBeans){
   	 this.suppliersPageBeans =suppliersPageBeans  ;
  }
  public  int getStart( ) {
   	 return this.start;
  }
  public  int getLimit( ) {
   	 return this.limit;
  }
  public  int getTotalProperty( ) {
   	 return this.totalProperty;
  }
  public    List<Suppliers> getSuppliersPageBeans(){
   	 return this.suppliersPageBeans   ;
  }
  public  String getInfo( ) {
   	 return this.info;
  }
  public  void setInfo(String info){
   	 this.info = info ;
  }
  public  boolean getSuccess( ) {
   	 return this.success;
  }
  public  void setSuccess(boolean success){
   	 this.success = success ;
  }

  @Action(value="insertSuppliers",results = {@Result(name = "success", type = "json")})
  public String  insertSuppliers() throws Exception{
   	success = false ;
   	info = "" ;
  	Suppliers bean = new Suppliers();
  	bean.setBianhao(this.bianhao); 
  	bean.setContact(this.contact); 
  	bean.setTelphone(this.telphone); 
  	bean.setFax(this.fax); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setHomepage(this.homepage); 
  	bean.setAddress(this.address); 
  	bean.setBlank(this.blank); 
  	bean.setAccount(this.account); 
  	bean.setStatus(this.status); 
  	bean.setCreateDate(this.createDate); 
	suppliersService.insert(bean);
   	success = true ;
   	info = "Add Successful" ;
   	return SUCCESS;
  }

  @Action(value="querySuppliers",results = {@Result(name = "success", type = "json")})
  public String  querySuppliers() throws Exception{
  	Suppliers bean = new Suppliers();
  	bean.setDbid(this.dbid); 
  	bean.setBianhao(this.bianhao); 
  	bean.setContact(this.contact); 
  	bean.setTelphone(this.telphone); 
  	bean.setFax(this.fax); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setHomepage(this.homepage); 
  	bean.setAddress(this.address); 
  	bean.setBlank(this.blank); 
  	bean.setAccount(this.account); 
  	bean.setStatus(this.status); 
  	bean.setCreateDate(this.createDate); 
	suppliersService.selectByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="updateSuppliers",results = {@Result(name = "success", type = "json")})
  public String  updateSuppliers() throws Exception{
   	success = false ;
   	info = "" ;
  	Suppliers bean = new Suppliers();
  	bean.setDbid(this.dbid); 
  	bean.setBianhao(this.bianhao); 
  	bean.setContact(this.contact); 
  	bean.setTelphone(this.telphone); 
  	bean.setFax(this.fax); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setHomepage(this.homepage); 
  	bean.setAddress(this.address); 
  	bean.setBlank(this.blank); 
  	bean.setAccount(this.account); 
  	bean.setStatus(this.status); 
  	bean.setCreateDate(this.createDate); 
  	bean =suppliersService.selectByPrimaryKey(bean);
  	bean.setDbid(this.dbid); 
  	bean.setBianhao(this.bianhao); 
  	bean.setContact(this.contact); 
  	bean.setTelphone(this.telphone); 
  	bean.setFax(this.fax); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setHomepage(this.homepage); 
  	bean.setAddress(this.address); 
  	bean.setBlank(this.blank); 
  	bean.setAccount(this.account); 
  	bean.setStatus(this.status); 
  	bean.setCreateDate(this.createDate); 
	suppliersService.updateByPrimaryKeySelective(bean);
   	success = true ;
   	info = "Update Successful" ;
   	return SUCCESS;
  }

  @Action(value="deleteSuppliers",results = {@Result(name = "success", type = "json")})
  public String  deleteSuppliers() throws Exception{
  	Suppliers bean = new Suppliers();
  	bean.setDbid(this.dbid); 
  	bean.setBianhao(this.bianhao); 
  	bean.setContact(this.contact); 
  	bean.setTelphone(this.telphone); 
  	bean.setFax(this.fax); 
  	bean.setMobile(this.mobile); 
  	bean.setEmail(this.email); 
  	bean.setZipcode(this.zipcode); 
  	bean.setHomepage(this.homepage); 
  	bean.setAddress(this.address); 
  	bean.setBlank(this.blank); 
  	bean.setAccount(this.account); 
  	bean.setStatus(this.status); 
  	bean.setCreateDate(this.createDate); 
	suppliersService.deleteByPrimaryKey(bean);
   	return SUCCESS;
  }

  @Action(value="listSuppliers",results = {@Result(name = "success", type = "json")})
  public String  listSuppliers() throws Exception{
 	QryCondition qry = RequestUtil.getQryCondition(   (javax.servlet.http.HttpServletRequest)com.opensymphony.xwork2.ActionContext.getContext().get(org.apache.struts2.ServletActionContext.HTTP_REQUEST)); 	PageBean pageBean = new PageBean();
	pageBean.setPageSize( limit );
	pageBean.setStartCount( start );
	totalProperty =suppliersService.getTotalRecords( qry, pageBean );
	suppliersPageBeans =suppliersService.getOnePageBeans( qry, pageBean );
   	return SUCCESS;
  }

  @Action("index")
  public String index() throws Exception{
   	return SUCCESS;
  }

}
